namespace Lays.Manage.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class AddNews : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.News",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(maxLength: 100),
                        Content = c.String(maxLength: 50),
                        Author = c.String(maxLength: 4000),
                        PublishedTime = c.DateTime(),
                        ClickCount = c.Int(nullable: false),
                        IsTop = c.Boolean(nullable: false),
                        IsPicture = c.Boolean(nullable: false),
                        CommentCount = c.Int(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_News_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Comments",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CommentContent = c.String(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                        News_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.News", t => t.News_Id)
                .Index(t => t.News_Id);
            
            CreateTable(
                "dbo.NewsTypes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Type = c.String(),
                        ParentId = c.Int(nullable: false),
                        Order = c.Int(nullable: false),
                        Desc = c.String(),
                        News_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.News", t => t.News_Id)
                .Index(t => t.News_Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.NewsTypes", "News_Id", "dbo.News");
            DropForeignKey("dbo.Comments", "News_Id", "dbo.News");
            DropIndex("dbo.NewsTypes", new[] { "News_Id" });
            DropIndex("dbo.Comments", new[] { "News_Id" });
            DropTable("dbo.NewsTypes");
            DropTable("dbo.Comments");
            DropTable("dbo.News",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_News_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
        }
    }
}
